package com.niguang.work.api.vo;


import com.niguang.work.api.entity.WechatPageUser;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;


/**
 * 新员工入职列表
 */
@Data
public class NewUserEntryVo {

    /**
     * 工种
     */
    private String workTypeName;

    /**
     * 工地ID
     */
    private String siteId;

    private String siteName;

    /**
     * 班组名称
     */
    private String teamUserName;

    private String teamUserPhone;

    /**
     * 班组名称
     */
    private String bzName;

    private String teamUserPic;

    private List<NewUserList> list;


    public NewUserEntryVo(String workTypeName, Long siteId, String siteName, String teamUserName, String teamUserPhone, String bzName, String teamUserPic) {
        this.workTypeName = workTypeName;
        this.siteId = String.valueOf(siteId);
        this.siteName = siteName;
        this.teamUserName = teamUserName;
        this.teamUserPhone = teamUserPhone;
        this.bzName = bzName;
        this.teamUserPic = teamUserPic;
    }

    public NewUserEntryVo() {
    }

    @Data
    public static class NewUserList {


        /**
         * 入职员工姓名
         */
        private String userName;


        /**
         * 入职员工手机号码
         */
        private String userPhone;


        /**
         * 入职员工身份证号码
         */
        private String userIdCard;

        /**
         * 入职员工时间
         */
        private String joinTime;

        private String sex;

        private String age;

        private String userPic;


        public static List<NewUserList> buildUserList(Long teamId, List<WechatPageUser> pageUserList) {
            List<WechatPageUser> userList = pageUserList.stream().filter(p -> p.getTeamId().equals(teamId)).collect(Collectors.toList());
            List<NewUserList> list = new ArrayList<>();
            userList.forEach(p1 -> {
                NewUserList newUserList = new NewUserList();
                BeanUtils.copyProperties(p1, newUserList);
                list.add(newUserList);
            });
            return list;
        }
    }


}
